map

type map<K: -immutable, V> : iterable<(K, V)>

Represents a mutable map that preserves entry iteration order.

Since

0.6.0

Constructors

Link copied to clipboard
pure constructor()

Creates an empty map.

pure constructor(entries: iterable<-map_entry<K,V>>)

Creates a map with the provided entries

Functions

Link copied to clipboard
function clear()

Clears the map.

Link copied to clipboard
pure function contains(key: K): boolean

Checks if the map contains a key.

Link copied to clipboard
pure function empty(): boolean

Checks if the map is empty.

Link copied to clipboard
pure function get(key: K): V

Gets the value associated with a key in the map. Fails if the key is not found.

Link copied to clipboard
pure function <R: +V> get_or_default(key: K, default: R): R

Gets the value associated with a key in the map, or a default value if the key is not found.

Link copied to clipboard
pure function get_or_null(key: K): V?

Gets the value associated with a key in the map, returning null if the key is not found.

Link copied to clipboard
pure function join_to_text([separator: text], [prefix: text], [postfix: text], [limit: integer?], [truncated: text], [transform: ((K, V)) -> text]): text

Creates a text from all the elements separated using separator and using the given prefix and postfix if supplied.

If the iterable is large, you can specify a non-negative value of limit, in which case only the first limit of elements will be appended, followed by the truncated text (which defaults to "...").

Link copied to clipboard
pure function keys(): set<K>

Returns a new set containing the keys of this map.

Link copied to clipboard
(alias) pure function len(): integer

Gets the size of the map.

Alias
Link copied to clipboard
function put(key: K, value: V)

Associates the specified value with the specified key in the map.

Link copied to clipboard
function put_all(map: map<-K, -V>)

Updates this map with key/value pairs from the specified map.

Link copied to clipboard
(alias) function putAll(map: map<-K, -V>)

Updates this map with key/value pairs from the specified map.

Alias
Link copied to clipboard
function remove(key: K): V

Removes a key-value pair from the map. Fails if the key is not found in the map.

Link copied to clipboard
function remove_or_null(key: K): V?

Removes a key-value pair from the map, returning null if the key is not found.

Link copied to clipboard
pure function size(): integer

Gets the size of the map.

Link copied to clipboard
(alias) pure function str(): text

Converts the map to text.

Alias
Link copied to clipboard
pure function to_text(): text

Converts the map to text.

Link copied to clipboard
pure function values(): list<V>

Returns a new list containing the values of this map.